# Maintainer: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Filip Dvorak <fila@pruda.com>

pkgname=enca
pkgver=1.19
pkgrel=4
pkgdesc="Charset analyser and converter"
arch=('x86_64')
url="https://cihar.com/software/enca/"
license=('GPL')
depends=('recode')
options=('!docs')
source=("https://dl.cihar.com/${pkgname}/${pkgname}-${pkgver}.tar.xz" enca-bad-file-descriptor.patch)
sha256sums=('3a487eca40b41021e2e4b7a6440b97d822e6532db5464471f572ecf77295e8b8'
            '270c7c0abaea5f3d10173b58849200d4106675d3127a0b9b8ce1fc3dcf775acb')

prepare() {
  cd $pkgname-$pkgver
  patch -p1 -i ../enca-bad-file-descriptor.patch # https://github.com/nijel/enca/issues/28
}

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr \
              --libexecdir=/usr/lib \
              --mandir=/usr/share/man \
              --with-librecode=/usr \
              --enable-external
  make
}

package() {
  cd ${pkgname}-${pkgver}

  make DESTDIR="${pkgdir}" install
}
